from datetime import timedelta, datetime

from config import parse


class Time:
    time = 0
    sim_time = 0
    begin_time = 0
    finish_time = 10
    step_size = 0.1

    @classmethod
    def init(cls):
        cls.begin_time = parse.Parse.get_sim_start_time()
        cls.finish_time = parse.Parse.get_sim_finish_time()
        cls.step_size = parse.Parse.get_sim_step()

    @classmethod
    def update_time(cls):
        """更新仿真时间"""
        cls.time += cls.step_size
        if cls.is_begin():
            cls.sim_time += cls.step_size
            return cls.sim_time

    @classmethod
    def is_begin(cls):
        """判断是否开始仿真"""
        return cls.time >= cls.begin_time

    @classmethod
    def is_finish(cls):
        """判断是否结束仿真"""
        return cls.sim_time >= cls.finish_time + cls.begin_time
